/*
 * @lc app=leetcode.cn id=504 lang=typescript
 *
 * [504] 七进制数
 */

// @lc code=start
function convertToBase7(num: number): string {
    if (num === 0) return "0";
    let now = Math.abs(num);
    let result = "";
    while (now) {
        const last = now % 7;
        now = Math.floor(now / 7);
        result = last + result;
    }
    return num < 0 ? "-" + result : result;
}
// @lc code=end
